import os, time
from selenium import webdriver

chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"  # 浏览器驱动位置
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)

driver.get('https://www.baidu.com')
# 获取cookie
cookies = driver.get_cookies()
# 添加cookie
driver.add_cookie({'name': 'aaaaaa', 'value': 'bbbbb'})
for cook in driver.get_cookies():
    print(cook['name'], cook['value'])
# print(cookies)
driver.quit()
